package com.sxbbc.common.core.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * app图标/banner图
 * 事件类型枚举
 * eventVal事件名称/hasVal是否有值/show是否显示
 *
 * @author leehao
 * @date 2019-05-14 11:34
 */
public enum EventEnums {
    SEARCH_PRODUCT("searchPro","商品查询","请填写商品编号","push:searchPro?",true,true),
    OWN_BUSINESS("ownBusiness","自营专区","不需要输入地址,后台自动查询","push:ownBusiness",false,true),
    GROUP("group","团购专区","不需要输入地址","push:group",false,true),
    SECKILL("seckill","秒杀专区","不需要输入地址","push:seckill",false,true),
    RECHARGE("recharge","充值中心","不需要输入地址","push:recharge",false,true),
    CLASSIFICATION("classification","跳转分类","请选择分类","push:classification",true,true),
    CLASSIFICATION_ALL("classificationAll","跳转分类全部","不需要输入地址","push:classificationAll",false,true),
    POINT("point","积分商城","不需要输入地址","push:point",false,true);

    private String url;
    private String name;
    private String remark;
    private String eventVal;
    private boolean hasVal;
    private boolean show;

    EventEnums(String url, String name, String remark, String eventVal, boolean hasVal, boolean show) {
        this.url = url;
        this.name = name;
        this.remark = remark;
        this.eventVal = eventVal;
        this.hasVal = hasVal;
        this.show = show;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getEventVal() {
        return eventVal;
    }

    public void setEventVal(String eventVal) {
        this.eventVal = eventVal;
    }

    public boolean isHasVal() {
        return hasVal;
    }

    public void setHasVal(boolean hasVal) {
        this.hasVal = hasVal;
    }

    public boolean isShow() {
        return show;
    }

    public void setShow(boolean show) {
        this.show = show;
    }

    /**
     * 查询所有列表
     */
    public static List<EventEnums> queryAllList() {
        List<EventEnums> list = new ArrayList<EventEnums>();
        for (EventEnums o : EventEnums.values()) {
            list.add(o);
        }
        return list;
    }

    /**
     * 查询show为true的列表
     */
    public static List<EventEnums> queryShowList() {
        List<EventEnums> list = new ArrayList<EventEnums>();
        for (EventEnums o : EventEnums.values()) {
            if (o.isShow()) {
                list.add(o);
            }
        }
        return list;
    }

    public static String getName(String ext) {
        String str = "";
        for (EventEnums o : EventEnums.values()) {
            if (o.getUrl().equals(ext)) {
                str = o.getName();
                break;
            }
        }
        return str;
    }

    public static EventEnums getObject(String event) {
        EventEnums enums = null;
        for (EventEnums o : EventEnums.values()) {
            if (o.getUrl().equals(event)) {
                enums = o;
                break;
            }
        }
        return enums;
    }
}
